package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.query.TravelQueryObject;
import cn.wolfcode.trip.base.service.ITravelService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/strategyTravel")
public class StrategyTravelController {
    @Autowired
    private ITravelService travelService;


    @RequestMapping("queryByStrategyId")
    public String queryByStrategyId(Model m,@ModelAttribute("qo")TravelQueryObject qo){
        m.addAttribute("pageInfo",travelService.queryByStrategyId(qo));
        return "/strategyTravel/list";
    }

    @RequestMapping("/queryTravel")
    @ResponseBody
    public Object queryTravel(TravelQueryObject qo){
        return travelService.queryTravel(qo);
    }

    @RequestMapping("/save")
    @ResponseBody
    public Object saveRelation(Long strategyId,Long travelId ){
        travelService.saveRelation(strategyId,travelId);
        return new JSONResult();
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(Long strategyId,Long travelId ){
        travelService.delete(strategyId,travelId);
        return new JSONResult();
    }

}
